#ifndef FETCHER_H
#define FETCHER_H

#include <stdbool.h> // <-- 关键修复：包含头文件
#include "thread_pool.h"
#include <glib.h> // fetcher_t 中用到了 GHashTable

typedef struct {
    char *registry_url;
    char *repository;
    thread_pool_t *download_pool;
    GHashTable *in_flight_hashes;
    pthread_mutex_t inflight_lock;
} fetcher_t;

typedef struct {
    fetcher_t *fetcher;
    char* hash;
    void* buffer;
    void (*callback)(void* arg, bool success);
    void* callback_arg;
} fetch_task_arg_t;

fetcher_t* fetcher_create(const char* registry_url, const char* repository, int num_threads);
void fetcher_destroy(fetcher_t* f);
void fetcher_fetch_chunk(fetcher_t* f, const char* hash, void (*callback)(void*, bool), void* callback_arg);

#endif